export function chanrole(data: any) {
    const parentMap = new Map();
    const result = [];
    // 首先遍历所有元素，创建父节点并存入Map
    for (const item of data) {
        if (item.type === '1') {
            const parent = { ...item, children: [] };
            parentMap.set(item.permissionid, parent);
            result.push(parent);
        }
    }
    // 再次遍历，将子节点添加到对应的父节点
    for (const item of data) {
        if (item.type === '2') {
            const parent = parentMap.get(item.permissionid);
            if (parent) {
                parent.children.push(item);
            }
        }
    }
    return result;
}